"""Build placement code"""


def scons():
    """Execute build"""
    Import('env', 'prereqs', 'libdaos_tgts')

    env.AppendUnique(LIBPATH=[Dir('.')])

    env.require('isal')

    denv = env.Clone()

    libraries = ['isal']

    # Common placement code
    common_tgts = denv.SharedObject(['pl_map.c', 'ring_map.c', 'jump_map.c',
                                     'jump_map_versions.c', 'pl_map_common.c'])
    # placement client library
    libdaos_tgts.extend(common_tgts)

    if not prereqs.server_requested():
        return

    # generate server module
    srv = denv.d_library('placement', common_tgts, install_off="../..", LIBS=libraries)
    denv.Install('$PREFIX/lib64/daos_srv', srv)


if __name__ == "SCons.Script":
    scons()
